package org.bing.zion.handler;

import org.bing.engine.common.logging.Log;
import org.bing.engine.common.logging.LogFactory;
import org.bing.zion.core.MessageHandler;
import org.bing.zion.core.MessageHandlerChain;
import org.bing.zion.core.Session;

public abstract class HandlerAdapter implements MessageHandler {
	protected static final Log logger = LogFactory.getLog(HandlerAdapter.class);

	public final void handle(MessageHandlerChain chain, Session session, Object msg) {
		try {
			doHandle(chain, session, msg);
		} catch (Throwable t) {
			logger.error("Fail to do " + this.getClass().getName(), t);
		}
		chain.next().handle(chain, session, msg);
	}

	public abstract void doHandle(MessageHandlerChain chain, Session session, Object msg);

}
